﻿using System;

namespace TextEditor
{
   

    public class A_AlignTCCenter : A_Action
    {
        public override string ActionName()
        {
            return "aligntccenter";
        }

        public override int CheckState()
        {
            ZYTextTableCell inTableCell = base.myOwnerDocument.GetInTableCell(base.myOwnerDocument.Content.CurrentElement);
            if (inTableCell != null)
            {
                if (inTableCell.Align == TableCellAlign.Center)
                {
                    return 1;
                }
                return 0;
            }
            return 0;
        }

        public override bool Execute()
        {
            if (this.CheckState() == 1)
            {
                base.myOwnerDocument.SetTCAlign(TableCellAlign.Top);
            }
            else
            {
                base.myOwnerDocument.SetTCAlign(TableCellAlign.Center);
            }
            return true;
        }

        public override bool isEnable()
        {
            return base.myOwnerDocument.CanModify();
        }
    }
}

